package cn.zhf.shop.controller;

import cn.zhf.shop.entity.Cooperation;
import cn.zhf.shop.entity.Message;
import cn.zhf.shop.service.CooperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "合作管理")
@RequestMapping("/api/Cooperation")
public class CooperationController {
    @Resource
    private CooperationService cooperationService;

    @ApiOperation(value = "根据合作id获取记录")
    @GetMapping("/id")
    public Message selectById(int id){
        return cooperationService.selectByPrimaryKey(id);
    }

    @ApiOperation(value = "获取全部合作")
    @GetMapping("/all")
    public Message selectAll(){
        return cooperationService.selectAll();
    }

    @ApiOperation(value = "增加合作")
    @PostMapping("/")
    public Message insert(Cooperation cooperation){
        return cooperationService.insertSelective(cooperation);
    }

    @ApiOperation(value = "根据id删除记录")
    @DeleteMapping("/")
    public Message delete(int id){
        return cooperationService.deleteByPrimaryKey(id);
    }

    @ApiOperation(value = "修改合作记录")
    @PutMapping("/")
    public Message update(Cooperation cooperation){
        return cooperationService.updateByPrimaryKeySelective(cooperation);
    }
}
